package game;

import java.util.ArrayList;
import java.util.List;

/**
 * 创建一副扑克牌，52张，按照花色及数字大小顺序添加到cardList中
 */
public class CardList {
    private List cardList;

    public CardList() {
        cardList = new ArrayList();
    }

    public List getCardList() {
        return cardList;
    }

    public void setCardList(List cardList) {
        this.cardList = cardList;
    }

    /**
     * 添加扑克牌
     */
    public void addCardList() {
        String[] str = {"黑桃", "红桃", "梅花", "方片"};
        String[] strCard = {"A", "K", "Q", "J"};
        int k=52;
        for(int i=0;i<4;i++){
            String card=strCard[i];
            for (int j = 0; j < 4; j++) {
                String colour = str[j];
                cardList.add(new Card(card, colour, k));
                k--;
            }
        }

        for (int i = 10; i > 1; i--) {
            for (int j = 0; j < 4; j++) {
                String colour = str[j];
                Card c = new Card(i + "", colour, k);
                cardList.add(c);
                k--;
            }

        }
    }

    /**
     * 获取扑克牌
     */
    public void getCard() {
        System.out.println("一副扑克牌如下：");
        for (int i = 0; i < cardList.size(); i++) {
            Card c = (Card) cardList.get(i);
            System.out.print(c.getColour() + c.getNumber()+" ");
        }
    }

    //测试添加的扑克牌和获取扑克牌方法是否正确
//    public static void main(String[] args) {
//        CardList cl = new CardList();
//        cl.addCardList();
//        cl.getCard();
//    }


}
